package com.jinmdz.fmis.mapper.mapper;

import org.apache.ibatis.annotations.*;
import com.jinmdz.fmis.mapper.mapper.provider.FuneralBusinessProvider;
import com.jinmdz.fmis.mapper.entity.FuneralBusinessEntity;

import java.util.ArrayList;

/**
 * 殡葬业务表Mapper
 * 
 * @author generator
 * @date 2020-08-23 18:11
 */
public interface FuneralBusinessMapper {

    /**
     * 增加FuneralBusiness
     * 
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-08-23 18:11
     */
    @InsertProvider(type = FuneralBusinessProvider.class, method = "insertFuneralBusiness")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertFuneralBusiness(@Param("entity") FuneralBusinessEntity entity);

    /**
     * 删除FuneralBusiness
     * 
     * @param id 主键
     * @param modifiedUserId 修改用户外键
     * @param version 版本号
     * @return
     * @author generator
     * @date 2020-08-23 18:11
     */
    @Update(" update funeral_business set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForFuneralBusiness(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改FuneralBusiness
     * 
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-08-23 18:11
     */
    @UpdateProvider(type = FuneralBusinessProvider.class, method = "updateFuneralBusiness")
    void updateFuneralBusiness(@Param("entity") FuneralBusinessEntity entity);

    /**
     * 查询FuneralBusiness实体
     * 
     * @param id 主键
     * @return FuneralBusinessEntity
     * @author generator
     * @date 2020-08-23 18:11
     */
    @Select(" select id,deleted,business_code,dead_name,member_name,remark,as_verified,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from funeral_business where id = #{id} and deleted = 0 limit 1 ")
    FuneralBusinessEntity getFuneralBusinessById(@Param("id") Integer id);

    /**
     * 查询FuneralBusiness列表
     * 
     * @param entity 数据实体
     * @return FuneralBusinessEntity
     * @author generator
     * @date 2020-08-23 18:11
     */
    @SelectProvider(type = FuneralBusinessProvider.class, method = "listFuneralBusiness")
    ArrayList<FuneralBusinessEntity> listFuneralBusiness(@Param("entity") FuneralBusinessEntity entity);
}